package t1000;

import java.util.Scanner;

/**
 * 姓名： 张东升
 * 日期: 2025年3月10日
 */
public class Main {

    public static int currLength;
    public static int position = -1;
    public static String findNumber;

    public static void main(String[] args) {

        // 创建数组
        Scanner sc = new Scanner(System.in);
        String[] arr = createArray(sc);
        System.out.println("The length:" + currLength);
        // 输出数组
        System.out.println("The elements:");
        sell(arr);
        display(arr);
        System.out.println("");
        fondElement(arr);
        System.out.println(position == -1 ? "No found" : "Found position:" + position);
        System.out.println("The length:" + currLength);
        System.out.println("The elements:");
        sell(arr);
        display(arr);
    }

    /**
     * 创建数组
     *
     * @param sc
     * @return
     */
    public static String[] createArray(Scanner sc) {
        //获取用户输入
        String str = sc.nextLine();
        char[] cs = str.toCharArray();
        for (int i = 0; i < cs.length; i++) {
            if (cs[i] == ' ') {
                continue;
            } else if (cs[i] == '0') {
                findNumber = cs[i + 2] + "";
                break;
            } else {
                currLength++;
            }
        }


        //开始创建数组
        String[] arr = new String[currLength];
        for (int i = 0, j = 0; i < cs.length; i++) {
            if (j == currLength) {
                break;
            }

            if (cs[i] != ' ') {
                arr[j] = cs[i] + "";
                j++;
            }

        }
        return arr;
    }

    /**
     * 输出数组
     *
     * @param arr
     */

    public static void display(String[] arr) {
        for (int i = 0; i < currLength; i++) {
            System.out.print(arr[i] + " ");
        }
    }

    /**
     * 排序
     *
     * @param arr
     */
    public static void sell(String[] arr) {
        int n = currLength / 2;

        for (int i = 0, j = currLength - 1; i < n; i++, j--) {
            String t = arr[i];
            arr[i] = arr[j];
            arr[j] = t;
        }
    }


    public static void fondElement(String[] arr) {
        for (int i = 0; i < currLength; i++) {
            if (arr[i].equals(findNumber)) {
                position = i + 1;
            }
        }
    }
}